require('../css/running.less');
require('../css/commom/basic.css');
document.ready(function(){
    let mewClass=document.querySelector('.mewClass');
    let listBox=document.querySelector('.listBox');

    
    
    utils.footerAll('running')
    // 获取课程列表
    let user=JSON.parse(localStorage.getItem('user'))
    $http.get('/sports/courseList?id='+user.userId,function(res){
        let newLatest=res.data;
        let resLatest=newLatest.find(function(item){
            return item.latest===1;
        })
        let html=`<a href="./train.html?id=${resLatest.courseId}">
         <div class="newTitle">最新课程</div>
        <div class="newBox">
            <div class="newPicture"> 
            <img src="${commomHttp+resLatest.imgurl}" class="newImg">
            </div>
            <div class="newScript">
                <p class="f16 ml16 newTop">${resLatest.name}</p>
                <div class="f12 ml16 fr154 newButtom">${resLatest.desc}</div>
            </div>
        </div>
        </a>
       
        `;
        mewClass.innerHTML=html;

        // 渲染全部课程
        let allHtml='';
        console.log(newLatest);
        newLatest.forEach(function(item){

            allHtml+=`
                <div id="classPicturn" class="mb15">
                <a href="./train.html?id=${item.courseId}">
                 <img src="${commomHttp+item.imgurl}" alt="" class="otherPicture">
                </a>    
                <div class="positionBox">
                         <p class="f16 ml16">${item.name}</p>
                         <div class="f12 ml16 fr154 newButtom">${item.desc}</div>
                    </div>
                </div>
            `
        })

        listBox.innerHTML=allHtml;
   
       
       
    })


})